package com.info.zhiduoduo.repository.mapper.project;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.entity.project.NonstandardProject;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface NonstandardProjectMapper extends BaseMapper<NonstandardProject> {

    @Select("select np.*,(SELECT GROUP_CONCAT(managername) from zdd_system_manager where FIND_IN_SET(managerid,np.follow_by)) as followByNames" +
            " from zdd_nonstandard_project np " +
            " where " +
            " (np.create_by = #{currUserId} or FIND_IN_SET(#{currUserId},np.follow_by) or 4 = #{roleid} )" +
            " and np.compname like '%${compname}%' " +
            " and if(ISNULL(#{createStartTime}), 1=1, DATE(np.create_time) >= DATE(#{createStartTime})) " +
            " and if(ISNULL(#{createEndTime}), 1=1, DATE(np.create_time) <= DATE(#{createEndTime})) " +
            "")
    List<NonstandardProject> queryList(Integer currUserId,Integer roleid, String compname, Date createStartTime, Date createEndTime);

    //查询未完成数量
    @Select("select count(1) " +
            " from zdd_nonstandard_project np " +
            " where " +
            " (np.create_by = #{currUserId} or FIND_IN_SET(#{currUserId},np.follow_by) or 4 = #{roleid} )" +
            " and np.state != 2")
    int queryIncompleteNum(Integer currUserId,Integer roleid);
}
